package com.tledu.production.service.system.impl;

import com.tledu.production.mapper.system.SysRoleResMapper;
import com.tledu.production.service.system.ISysRoleResService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * 角色资源
 *
 * @author Antg
 * @date 2021/8/19  10:39
 */
@Service
@AllArgsConstructor
public class SysRoleResServiceImpl implements ISysRoleResService {
    private SysRoleResMapper sysRoleResMapper;


    @Override
    public Integer[] findRoleRes(String roleId) {
        String roleRes = sysRoleResMapper.findRoleRes(roleId);
        if (roleRes == null) {
            return null;
        }
        String[] resIdList = roleRes.split(",");
        Integer[] ids = new Integer[resIdList.length];
        for (int i = 0; i < resIdList.length; i++) {
            ids[i] = Integer.parseInt(resIdList[i]);
        }
        return ids;
    }

    @Override
    public int updateRoleRes(String roleId, String resList) {
        return sysRoleResMapper.updateRoleRes(roleId, resList);
    }
}
